package com.twu.biblioteca;

import sun.misc.BASE64Encoder;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Account {
    public static String[][] users= new String[][]{
            {"0000-000",MD5("xxxx"),"Alex","0000@gmail.com","0000"},
            {"0000-001",MD5("1234"),"Bob","1111@google.com","1234"},
            {"0000-002",MD5("5678"),"Cyning","2222@163.com","5678"},
            {"0000-003",MD5("9012"),"Denil","3333@thoughtworks.com","9012"}};

    public static String MD5(String pwd)
    {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        BASE64Encoder base = new BASE64Encoder();
        if(md == null) {
            return null;
        } else {
            return base.encode(md.digest(pwd.getBytes()));
        }
    }
}
